package atguigu.gson;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
    @Expose()
    private int id; // 参与序列化/反序列化
    @SerializedName("login_name")
    @Expose(serialize = false,deserialize = false)
    private String name; // 不参与序列化，也不参与反序列化
    @Expose(serialize = false, deserialize = true)
    private Integer age; // 只参与反序列化
    @Expose(serialize = true, deserialize = false)
    private Job job; // 只参与序列化

    private transient List<String> nickName;

    public User(int id, String name, Integer age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }
}